export let setProductPrice = function (price){
  let ProductPrice = ''
  let s = Object.prototype.toString.call(price);
  let type = s.match(/\[object (.*?)\]/)[1].toLowerCase(price);
  if (type === 'string' || type === 'number') {
    if (Number(price).toString() !== 'NaN' && price !== '') {
      ProductPrice =  Math.floor (numMulti(price, 100)) / 100
      if (Number.isInteger(ProductPrice)) {
        ProductPrice = ProductPrice.toString() + '.00'
      } else if (2 - ProductPrice.toString().split('.')[1].length === 1) {
        ProductPrice = ProductPrice.toString() + '0'
      }
    } else {
      ProductPrice = '待定'
    }
  }else {
    ProductPrice = '待定'
  }
  return ProductPrice
};

export let numMulti = function(num1, num2) { 
  if (!num1 || !num2) {
    return false 
  }
  var baseNum = 0; 
  try { 
    baseNum += num1.toString().split(".")[1].length; 
  } catch (e) { 
  } 
  try { 
    baseNum += num2.toString().split(".")[1].length; 
  } catch (e) { 
  } 
  return Number(num1.toString().replace(".", "")) 
  * Number(num2.toString().replace(".", "")) / Math.pow(10, baseNum); 
}